<template>
  <div class="not-found">
    <img src="@/assets/images/404.png" alt="404" />
    <div>
      页面不存在，还剩 <span class="countdown">{{ countdown }}</span> 秒返回首页
    </div>
    <button @click="goHome">立即返回首页</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      countdown: 5,
    };
  },
  methods: {
    goHome() {
      if(!this.$storage.has("token")){
        this.$router.push("/");
      }

      if (this.$kunUtil.judgeUserType() === this.$sys.userType.ADMIN){
        this.$router.push("/kunIndex")
      }
      else this.$router.push("/");
    },
  },
  mounted() {
    const interval = setInterval(() => {
      if (this.countdown > 0) {
        this.countdown--;
      } else {
        clearInterval(interval);
        this.goHome();
      }
    }, 1000);
  },
};
</script>

<style scoped>
.not-found {
  display: flex;
  /* justify-content: center; */
  align-items: center;
  flex-direction: column;
  height: 100vh;
}

.not-found img {
  width: 300px;
  height: 300px;
}

.not-found div {
  margin-top: 40px;
  font-size: 18px;
  color: #999;
}

.not-found .countdown {
  font-size: 24px;
  color: #ff0000;
}

.not-found button {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: #409eff;
  border: none;
  color: white;
  border-radius: 5px;
  transition: background-color 0.3s;
}

.not-found button:hover {
  background-color: #66b1ff;
}
</style>
